<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>检测网络</title>
</head>
<body>

</body>
<script type="text/javascript">
   /* var EventUtil = {
	    addHandler: function (element, type, handler) {
	        if (element.addEventListener) {
	            element.addEventListener(type, handler, false);
	        } else if (element.attachEvent) {
	            element.attachEvent("on" + type, handler);
	        } else {
	            element["on" + type] = handler;
	        }
	    },
	    removeHandler: function (element, type, handler) {
	        if (element.removeEventListener) {
	            element.removeEventListener(type, handler, false);
	        } else if (element.detachEvent) {
	            element.detachEvent("on" + type, handler);
	        } else {
	            element["on" + type] = null;
	        }
	    }
	};
	
	
	var dom = document.createElement('img');
	dom.style = 'display:none;';
	dom.src = 'http://www.baidu.com/img/bdlogo.gif';
	dom.id = 'map_img';
	EventUtil.addHandler(dom, 'error', function(){
		alert('你的电脑没有链接网络，连接上网络后才能打开地图！');
	});
	document.body.appendChild(dom); */
	
	
	(function testNetwork() {
		window.isNetwork = true;
		var dom = document.createElement("img");
		dom.style = "display:none;"
		dom.src = "http://www.baidu.com/img/bdlogo.gif";
		if(dom.addEventListener) {
			dom.addEventListener("error", handler, false);
		} else {
			dom.attachEvent("onerror", handler)
		}
		function handler() {
			window.isNetwork = false;
		}
		document.body.appendChild(dom);
	})();
	
</script>
</html>